﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.enprise
{
    public partial class RegisterEnterpriseIntroduce : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Application["webname"] != null)
                {
                    this.Title = string.Format("单位会员注册：单位介绍  {0}", Application["webname"].ToString());
                }
                if (Session["enterprise_model"] == null)
                {
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this, "请先填写“单位信息&bull;联系方式”！", "RegisterEnterprise.html");
                }
            }
        }

        protected void btn_save_Click(object sender, EventArgs e)
        {
            if (this.txtabout.Text.Length < 50)
            {
                Maticsoft.Common.MessageBox.Show(this,"对不起，您的单位介绍过于简短，请填写50字以上。");
            }
            else
            {
                string about = this.txtabout.Text;

                //去除脚本
                about = Regex.Replace(about, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);

                lcmyjobs.Model.enterprise_basic model = Session["enterprise_model"] as lcmyjobs.Model.enterprise_basic;
                model.about = about;
                Session["enterprise_model"] = model;
                Response.Redirect("RegisterPostJobs.html");

/*
                lcmyjobs.BLL.enterprise_basic bm = new BLL.enterprise_basic();

                if (Session["enterprise_model"] != null)
                {
                    lcmyjobs.Model.enterprise_basic model = Session["enterprise_model"] as lcmyjobs.Model.enterprise_basic;

                    model.about = about;

                    int enterprise_bid = bm.Add(model);

                    if (enterprise_bid > 0)
                    {
                        lcmyjobs.Model.jobsCount jc = new Model.jobsCount();

                        jc.jobsTotalCount = 5;
                        jc.jobsPubCount = 0;
                        jc.isFristJobsCount = 0;
                        jc.fristJobCount = 0;

                        Session["jobsCountRegister"] = jc;//记录刚注册会员(试用会员)的权限
                        Session["enterprise_bid"] = enterprise_bid;
                        Session["enterprise_name"] = model.name;
                        Maticsoft.Common.MessageBox.ShowAndRedirect(this, "恭喜您成为我站单位会员！", "RegisterPostJobs.aspx");
                    }
                    else
                    {
                        Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存失败！请重新填写保存。", "RegisterEnterprise.aspx");
                    }


                }
 */
            }

        }


    }
}